<?php

namespace App\Models;

use App\Common\Constant\Params;
use Illuminate\Database\Eloquent\Model;

class OrderOffer extends BaseModel
{

    protected $table = 'orders_offer';

    const CREATED_AT = 'add_time';
    const UPDATED_AT = 'upd_time';

    protected $dateFormat = 'U';

    protected $fillable = [
        'order_id',
        'master_id',
        'price',
        'message',
        'status'
    ];

    protected $touches = ['order'];

    public function order(){
        return $this->belongsTo(Order::class,'order_id');
    }

    public function master(){
        return $this->belongsTo(Master::class,'master_id');
    }

    /**
     * 已雇佣
     */
    public function getEmployedAttribute()
    {
        return $this->status == Params::OFFER_STATUS_EMPLOYED;
    }

    /**
     * 获取雇佣状态文本
     */
    public function getStatusTextAttribute()
    {
        return Params::$OFFER_STATUS[$this->status];
    }

}
